#ifndef SVN_COMMAND_H_INCLUDED
#define SVN_COMMAND_H_INCLUDED

#include <wx/string.h>
#include "singleton.h"

namespace svn
{

/**
 * @class Command
 * @brief Manage SVN command
 * It's a SVN interface class
 */
class Command
{
private:
	wxString m_sSvnCmd;
	bool     m_bInstalled;

public:
	Command(const wxString& sSvnCmd = wxT("svn"));

	bool SetSvnCommand(const wxString& sSvnCmd);

	const wxString& GetSvnCommand() const { return m_sSvnCmd; }


	/**
	 * @brief Ask if SVN is curently installed or not
	 *
	 * @return true if svn is installed
	 */
	bool IsInstalled() const { return m_bInstalled; };

	/**
	 * @brief Get the revision of an SVN object
	 *
	 * @param rRevision [out] SVN revision
	 * @param sPath      path of the SVN object
	 *
	 * @return true if the revision was found
	 */
	bool GetRevision(long& rRevision, const wxString& sPath = wxT("."));

protected:
	bool Execute(const wxString& sArgs, wxString* pOutput = NULL) const;
};

typedef Singleton<Command> TSvnCommand;

static
long get_revision(long& rRevision, const wxString& sPath = wxT("."))
{
	return TSvnCommand::Get()->GetRevision(rRevision, sPath);
}

static
const wxString& get_svn_cmd()
{
	return TSvnCommand::Get()->GetSvnCommand();
}

static
bool is_installed()
{
	return TSvnCommand::Get()->IsInstalled();
}

static
bool set_svn_cmd(const wxString& sSvnCmd)
{
	return TSvnCommand::Get()->SetSvnCommand(sSvnCmd);
}

};

#endif // SVN_COMMAND_H_INCLUDED
